import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from "../views/HomeView";
import LoginView from "../views/LoginView";
import AddArticleView from "../views/AddArticleView";

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        name: 'login',
        component: LoginView
    },
    {
        path: "/main",
        name: "main",
        component: HomeView,
        // DES: 通过children指定子路由
        children: [
            {
                path: 'list',
                name: 'list',
                component: () => import(/* webpackChunkName: "list" */ '../views/ArticleListView.vue')
            }, {
                path: 'mine',
                name: 'mine',
                component: () => import(/* webpackChunkName: "mine" */ '../views/MineView.vue')
            }
        ]
    },
    {
        path: "/add",
        name: "add",
        component: AddArticleView
    }
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
});

export default router
